loadstring(exports.dgs:dgsImportFunction())()
local sw,sh = guiGetScreenSize()
local px,py = sw/1366,sh/768
font = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 12*px )
font2 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 11*px )
font3 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 14*px )
font4 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 20*px )
cmtaLoginPanel = false

function createlogin()
effect3d = dgsCreateEffect3D(20)
sp = dgsCreateScrollPane(400*px,100*py,566*px,568*py,false,false)  
img = dgsCreateImage(0,0,1,1,_,true,sp,tocolor(0,0,0,140))  
dgsEffect3DApplyToScrollPane(effect3d,sp)

image = dxCreateTexture( "logo.png" ,"argb", false, "clamp" )
image2 = dgsCreateImage(200*px,-40*py,266*px,266*py,image,false,img)

edit1 = dgsCreateEdit( 170*px, 220*py, 326*px, 30*py, "", false,img )
edit2 = dgsCreateEdit( 170*px, 280*py, 326*px, 30*py, "", false,img )
dgsSetProperty(edit2,"masked",true)
dgsSetFont( edit1, font )
dgsSetFont( edit2, font )
dgsSetProperty(edit1,"alignment",{"center","center"})
dgsSetProperty(edit2,"alignment",{"center","center"})
button = dgsCreateButton( 210*px, 380*py, 246*px, 40*py, "Zaloguj", false,img,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
checklog = dgsCreateCheckBox(360*px, 320*py, 326*px, 30*py,"Zapamiętaj dane",false,false,img)
dgsSetFont( checklog, font )
load_rememberMe()

textlog1 = dgsCreateLabel(170*px,190*py,326*px,30*py,"Login:",false,img,tocolor(128,128,128))
dgsSetFont( textlog1, font )
dgsSetProperty(textlog1,"alignment",{"center","center"})
textlog2 = dgsCreateLabel(170*px,250*py,326*px,30*py,"Hasło:",false,img,tocolor(128,128,128))
dgsSetFont( textlog2, font )
dgsSetProperty(textlog2,"alignment",{"center","center"})
dgsSetFont( button, font )

textrecovery = dgsCreateLabel(200*px,465*py,266*px,25*py,"#DD6B20Przypomnij hasło",false,img)
dgsSetFont( textrecovery, font )
dgsSetProperty(textrecovery,"colorcoded",true)
dgsSetProperty(textrecovery,"alignment",{"center","top"})

textregister = dgsCreateLabel(190*px,495*py,286*px,25*py,"#808080Jesteś tutaj pierwszy raz? #DD6B20Stwórz konto",false,img)
dgsSetFont( textregister, font )
dgsSetProperty(textregister,"colorcoded",true)
dgsSetProperty(textregister,"alignment",{"center","top"})

text = dgsCreateLabel(0*px,520*py,666*px,50*py,"#ff0000Pamiętaj, że używanie niedozwolonego oprogramowania wiąże się ze stałą blokadą konta.",false,img)
dgsSetFont( text, font2 )
dgsSetProperty(text,"colorcoded",true)
dgsSetProperty(text,"alignment",{"center","center"})

end

function createregister()
effect3d2 = dgsCreateEffect3D(20)
sp2 = dgsCreateScrollPane(200*px,100*py,966*px,568*py,false,false) 
local img2 = dgsCreateImage(0,0,1,1,_,true,sp2,tocolor(0,0,0,140))  
dgsEffect3DApplyToScrollPane(effect3d2,sp2)

text1 = dgsCreateLabel(0*px,20*py,483*px,50*py,"#DD6B20Twoje dane do logowania na serwerze",false,img2)
dgsSetFont( text1, font )
dgsSetProperty(text1,"colorcoded",true)
dgsSetProperty(text1,"alignment",{"center","center"})

text2 = dgsCreateLabel(483*px,20*py,483*px,50*py,"#DD6B20Twoje dane do logowanian \nw panelu gracza dostępnym na forum",false,img2)
dgsSetFont( text2, font )
dgsSetProperty(text2,"colorcoded",true)
dgsSetProperty(text2,"alignment",{"center","center"})

edit1 = dgsCreateEdit( 140*px, 100*py, 203*px, 30*py, "", false,img2 )
edit2 = dgsCreateEdit( 140*px, 170*py, 203*px, 30*py, "", false,img2 )
edit3 = dgsCreateEdit( 140*px, 240*py, 203*px, 30*py, "", false,img2 )
edit4 = dgsCreateEdit( 140*px, 310*py, 203*px, 30*py, "", false,img2 )

edit5 = dgsCreateEdit( 623*px, 100*py, 203*px, 30*py, "", false,img2 )
edit6 = dgsCreateEdit( 623*px, 170*py, 203*px, 30*py, "", false,img2 )
edit7 = dgsCreateEdit( 623*px, 240*py, 203*px, 30*py, "", false,img2 )

dgsSetFont( edit1, font )
dgsSetFont( edit2, font )
dgsSetFont( edit3, font )
dgsSetFont( edit4, font )
dgsSetFont( edit5, font )
dgsSetFont( edit6, font )
dgsSetFont( edit7, font )


rndRect = dgsCreateRoundRect(0,false,tocolor(221,107,32,150))  
line = dgsCreateImage(482*px,20*py,3*px,400*py,rndRect,false,img2) 


textreg1 = dgsCreateLabel(140*px,70*py,203*px,30*py,"Login:",false,img2,tocolor(128,128,128))
dgsSetFont( textreg1, font )
dgsSetProperty(textreg1,"alignment",{"center","center"})

textreg2 = dgsCreateLabel(140*px,140*py,203*px,30*py,"Hasło:",false,img2,tocolor(128,128,128))
dgsSetFont( textreg2, font )
dgsSetProperty(textreg2,"alignment",{"center","center"})

textreg3 = dgsCreateLabel(140*px,210*py,203*px,30*py,"Powtórz Hasło:",false,img2,tocolor(128,128,128))
dgsSetFont( textreg3, font )
dgsSetProperty(textreg3,"alignment",{"center","center"})

textreg4 = dgsCreateLabel(140*px,280*py,203*px,30*py,"PIN (4 cyfry 0-9):",false,img2,tocolor(128,128,128))
dgsSetFont( textreg4, font )
dgsSetProperty(textreg4,"alignment",{"center","center"})

textreg5 = dgsCreateLabel(623*px,70*py,203*px,30*py,"Login:",false,img2,tocolor(128,128,128))
dgsSetFont( textreg5, font )
dgsSetProperty(textreg5,"alignment",{"center","center"})

textreg6 = dgsCreateLabel(623*px,140*py,203*px,30*py,"Hasło:",false,img2,tocolor(128,128,128))
dgsSetFont( textreg6, font )
dgsSetProperty(textreg6,"alignment",{"center","center"})

textreg7 = dgsCreateLabel(623*px,210*py,203*px,30*py,"E-mail:",false,img2,tocolor(128,128,128))
dgsSetFont( textreg7, font )
dgsSetProperty(textreg7,"alignment",{"center","center"})

textreg7 = dgsCreateLabel(623*px,300*py,203*px,30*py,"Wpisując niepoprawny E-mail tracisz możliwość\nodzyskania hasła do konta",false,img2,tocolor(255,40,40,190))
dgsSetFont( textreg7, font2 )
dgsSetProperty(textreg7,"alignment",{"center","center"})


button2 = dgsCreateButton( 300*px, 430*py, 366*px, 40*py, "Stwórz konto", false,img2,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
dgsSetFont( button2, font )


textlogin = dgsCreateLabel(360*px,495*py,246*px,25*py,"#808080Posiadasz już konto? #DD6B20Zaloguj się",false,img2)
dgsSetFont( textlogin, font )
dgsSetProperty(textlogin,"colorcoded",true)
dgsSetProperty(textlogin,"alignment",{"center","top"})

textinfo = dgsCreateLabel(0*px,520*py,966*px,50*py,"#808080Zakładając konto akceptujesz regulamin, który znajduje się pod adresem #ff2828https://clickermta.pl/",false,img2)
dgsSetFont( textinfo, font )
dgsSetProperty(textinfo,"colorcoded",true)
dgsSetProperty(textinfo,"alignment",{"center","center"})

end

local screenSize = Vector2(guiGetScreenSize())
local w = math.min(screenSize.x, screenSize.y)*0.8
local mnoz = w/3000

function refreshmap()
	for i,v in pairs(getElementsByType("player")) do
		x, y, z = getElementPosition(v)
		if getZoneName(x, y, z,true) == "San Fierro" then
			zone1 = (zone1 or 0) + 1
		end
		if getZoneName(x, y, z,true) == "Los Santos" then
			zone2 = (zone2 or 0) + 1
		end	
		if getZoneName(x, y, z,true) == "Las Venturas" then
			zone3 = (zone3 or 0) + 1
		end
		if getZoneName(x, y, z,true) == "Bone Country" then
			zone4 = (zone4 or 0) + 1
		end
	end
	
	
	
	local x,y,z = getElementPosition(localPlayer)
	local playerposition = getZoneName(x, y, z)
	local playerposition2 = getZoneName(x, y, z,true)
	spawns = {
		{"#ff2828Dostępne spawny:","nonvisible"},
		{"","nonvisible"},
		{"Los Santos\n#DD6B20Graczy w tym obszarze: "..(zone2 or 0).."","visible"},
		{"San Fierro\n#DD6B20Graczy w tym obszarze: "..(zone1 or 0).."","visible"},
		{"Las Venturas\n#DD6B20Graczy w tym obszarze: "..(zone3 or 0).."","visible"},
		{"Fort Carson\n#DD6B20Graczy w tym obszarze: "..(zone4 or 0).."","visible"},
		{"Dom\n#DD6B20"..playerposition.." ["..playerposition2.."]","visible"},
		{"Baza Gangu\n#DD6B20"..playerposition.." ["..playerposition2.."]","visible"},
		{"Ostatnia pozycja #D97319[V.I.P]\n#DD6B20"..playerposition.." ["..playerposition2.."]","visible"},
		{"Diler narkotyków #D97319[V.I.P]\n#DD6B20Dostępny w godzinach 18-10","visible"},
		{"Diler broni i amunicji #D97319[V.I.P]\n#DD6B20Dostępny w godzinach 6-23","visible"},
	
	
	}
end

addEvent("cmta_login:succeslogin", true)
addEventHandler("cmta_login:succeslogin", resourceRoot, function()
	refreshmap()
	save_rememberMe()
	destroyElement(image)
	destroyElement(effect3d)
	if isElement(effect3d4) then
	destroyElement(effect3d4)
	end
	destroyElement(sp)
	if isElement(sp4) then destroyElement(sp4) end
	effect3d3 = dgsCreateEffect3D(20)
	sp3 = dgsCreateScrollPane(150*px,50*py,1066*px,668*py,false,false) 
	img3 = dgsCreateImage(0,0,1,1,_,true,sp3,tocolor(0,0,0,140))  
	dgsEffect3DApplyToScrollPane(effect3d3,sp3)
	spawnimg = dxCreateTexture( "map.jpg" ,"argb", false, "clamp" )
    image3 = dgsCreateImage(screenSize.x/1.9-(w/2), screenSize.y/2.3-(w/2), w, w,spawnimg,false,sp3)

	for i,v in ipairs(getElementsByType("player")) do
		if getElementData(v,"player:data").uid then
		local x,y,z = getElementPosition(v)
		dgsCreateImage(screenSize.x/1.9+((x*mnoz)/2)-8, screenSize.y/2.3-((y*mnoz)/2)-8, 12, 12, "user.png", false, sp3)
		end
	end

	for i,v in ipairs(spawns) do
		label = dgsCreateLabel(5*px,(i*50)*py,90*px,20*py,tostring(v[1]),false,sp3)
		dgsSetFont( label, font3 )
		dgsSetProperty(label,"colorcoded",true)
		if v[2] == "visible" then
		dgsSetFont( label, font2 )
		end
	end
	spawnbutton1 = dgsCreateButton( 235*px,((3*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton2 = dgsCreateButton( 235*px,((4*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton3 = dgsCreateButton( 235*px,((5*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton4 = dgsCreateButton( 235*px,((6*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton5 = dgsCreateButton( 235*px,((7*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton6 = dgsCreateButton( 235*px,((8*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton7 = dgsCreateButton( 235*px,((9*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton8 = 	dgsCreateButton( 235*px,((10*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	spawnbutton9 = 	dgsCreateButton( 235*px,((11*50)*py)+5*py,90*px,20*py, "Spawn", false,sp3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	dgsSetFont( spawnbutton1, font )
	dgsSetFont( spawnbutton2, font )
	dgsSetFont( spawnbutton3, font )
	dgsSetFont( spawnbutton4, font )
	dgsSetFont( spawnbutton5, font )
	dgsSetFont( spawnbutton6, font )
	dgsSetFont( spawnbutton7, font )
	dgsSetFont( spawnbutton8, font )
	dgsSetFont( spawnbutton9, font )
	dgsSetEnabled(spawnbutton5,false)
	dgsSetEnabled(spawnbutton6,false)
end)

addEvent("cmta_login:pin", true)
addEventHandler("cmta_login:pin", resourceRoot, function()
dgsSetEnabled ( sp, false )
dgsEffect3DRemoveFromScrollPane(effect3d,sp)
effect3d4 = dgsCreateEffect3D(20)
sp4 = dgsCreateScrollPane(500*px,220*py,366*px,328*py,false,false) 
img4 = dgsCreateImage(0,0,1,1,_,true,sp4,tocolor(0,0,0,200))  
dgsEffect3DApplyToScrollPane(effect3d4,sp4)
textpin1 = dgsCreateLabel(0*px,50*py,366*px,30*py,"Potwierdzenie Tożsamości",false,img4,tocolor(255,40,40))
dgsSetFont( textpin1, font3 )
dgsSetProperty(textpin1,"alignment",{"center","center"})
textpin2 = dgsCreateLabel(0*px,120*py,366*px,30*py,"PIN:",false,img4,tocolor(221,107,32))
dgsSetFont( textpin2, font )
dgsSetProperty(textpin2,"alignment",{"center","center"})
edit8 = dgsCreateEdit( 100*px, 150*py, 166*px, 30*py, "", false,img4 )
dgsSetProperty(edit8,"maxLength",4)
pinbutton = dgsCreateButton( 50*px,220*py,266*px,30*py, "Zweryfikuj", false,img4,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
end)

function createrecovery()
	effect3d5 = dgsCreateEffect3D(20)
	sp5 = dgsCreateScrollPane(450*px,170*py,466*px,428*py,false,false) 
	img5 = dgsCreateImage(0,0,1,1,_,true,sp5,tocolor(0,0,0,200))  
	dgsEffect3DApplyToScrollPane(effect3d5,sp5)
	edit9 = dgsCreateEdit( 100*px, 150*py, 266*px, 30*py, "", false,img5 )
	edit10 = dgsCreateEdit( 100*px, 210*py, 266*px, 30*py, "", false,img5 )
	edit11 = dgsCreateEdit( 100*px, 270*py, 266*px, 30*py, "", false,img5 )
	dgsSetProperty(edit11,"maxLength",4)
	textrecovery0 = dgsCreateLabel(0*px,50*py,466*px,30*py,"Odzyskiwanie hasła",false,img5,tocolor(255,40,40))
	dgsSetFont( textrecovery0, font3 )
	dgsSetProperty(textrecovery0,"alignment",{"center","center"})
	textrecovery1 = dgsCreateLabel(0*px,120*py,466*px,30*py,"Login:",false,img5,tocolor(221,107,32))
	dgsSetFont( textrecovery1, font )
	dgsSetProperty(textrecovery1,"alignment",{"center","center"})
	textrecovery2 = dgsCreateLabel(0*px,180*py,466*px,30*py,"E-mail:",false,img5,tocolor(221,107,32))
    dgsSetFont( textrecovery2, font )
    dgsSetProperty(textrecovery2,"alignment",{"center","center"})
    textrecovery3 = dgsCreateLabel(0*px,240*py,466*px,30*py,"PIN:",false,img5,tocolor(221,107,32))
    dgsSetFont( textrecovery3, font )
    dgsSetProperty(textrecovery3,"alignment",{"center","center"})
	pinrecovery= dgsCreateButton( 50*px,340*py,366*px,30*py, "Potwierdź", false,img5,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	recoveryback= dgsCreateButton( 50*px,380*py,366*px,30*py, "Wróć do panelu logowania", false,img5,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))

end

addEvent("cmta_login:create_recovery", true)
addEventHandler("cmta_login:create_recovery", resourceRoot, function(login)
	destroyElement(effect3d5)
	destroyElement(sp5)
	recoverylogin = login
	effect3d6 = dgsCreateEffect3D(20)
	sp6 = dgsCreateScrollPane(450*px,170*py,466*px,428*py,false,false) 
	img6 = dgsCreateImage(0,0,1,1,_,true,sp6,tocolor(0,0,0,200))  
	dgsEffect3DApplyToScrollPane(effect3d6,sp6)
	edit12 = dgsCreateEdit( 100*px, 150*py, 266*px, 30*py, "", false,img6 )
	edit13 = dgsCreateEdit( 100*px, 210*py, 266*px, 30*py, "", false,img6 )
	edit14 = dgsCreateEdit( 100*px, 270*py, 266*px, 30*py, "", false,img6 )
	textrecovery4 = dgsCreateLabel(0*px,50*py,466*px,30*py,"Zmień hasło",false,img6,tocolor(255,40,40))
	dgsSetFont( textrecovery4, font3 )
	dgsSetProperty(textrecovery4,"alignment",{"center","center"})
	textrecovery5 = dgsCreateLabel(0*px,120*py,466*px,30*py,"Kod weryfikacyjny:",false,img6,tocolor(221,107,32))
	dgsSetFont( textrecovery5, font )
	dgsSetProperty(textrecovery5,"alignment",{"center","center"})
	textrecovery6 = dgsCreateLabel(0*px,180*py,466*px,30*py,"Nowe hasło:",false,img6,tocolor(221,107,32))
    dgsSetFont( textrecovery6, font )
    dgsSetProperty(textrecovery6,"alignment",{"center","center"})
    textrecovery7 = dgsCreateLabel(0*px,240*py,466*px,30*py,"Powtórz nowe hasło:",false,img6,tocolor(221,107,32))
    dgsSetFont( textrecovery7, font )
    dgsSetProperty(textrecovery7,"alignment",{"center","center"})
	pinrecovery2=dgsCreateButton( 50*px,340*py,366*px,30*py, "Zmień hasło", false,img6,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
	recoveryback2=dgsCreateButton( 50*px,380*py,366*px,30*py, "Wróć do panelu logowania", false,img6,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(221,107,32),tocolor(221,107,32))
end)

addEvent("cmta_login:create_loginpanel", true)
addEventHandler("cmta_login:create_loginpanel", resourceRoot, function()
	destroyElement(effect3d6)
	destroyElement(sp6)
	createlogin()
end)

-- KAMERA -- 
local sx,sy = guiGetScreenSize()

local texture = dxCreateTexture("mask.png","dxt5")
local texture2 = dxCreateTexture("mask2.png","dxt5")

local camX,camY,camZ,camX2,camY2,camZ2 = 2056, 1434, 159,2059.5166015625,1278.7858886719,89.821063995361
local lastCamTick = 0
local camDist = getDistanceBetweenPoints3D (camX,camY,camZ,camX2,camY2,camZ)
local currentCamAngle = 270
local lastClick = 0

function getPointFromDistanceRotation(x, y, dist, angle)
    local a = math.rad(90 - angle);
    local dx = math.cos(a) * dist;
    local dy = math.sin(a) * dist;
    return x+dx, y+dy;
end

function updateCamPosition ()
	local newCamTick = getTickCount ()
	local delay = newCamTick - lastCamTick
	lastCamTick = newCamTick
	local angleChange = delay/300
	currentCamAngle = currentCamAngle + angleChange
	local newX,newY = getPointFromDistanceRotation (camX,camY,camDist,currentCamAngle)
	setCameraMatrix (camX,camY,camZ,newX,newY,camZ2)
end

function maskEffect()
	dxDrawImage(0,0,sx,sy,texture2,0,0,0,tocolor(0,0,0,200))
	dxDrawImage(0,0,sx,sy,texture,0,0,0,tocolor(0,0,0,110))
end

addEventHandler("onClientResourceStart",resourceRoot,function()
if getElementData(localPlayer,"player:data") and getElementData(localPlayer,"player:data").uid then return end
if getElementData(localPlayer,"player:info_ban") then return end
triggerServerEvent("cmta_login:checkban", resourceRoot)
setElementPosition(localPlayer,0,0,500)
fadeCamera(true)
setCameraTarget(localPlayer, localPlayer)
setElementFrozen(localPlayer,false)
end)


addEvent("cmta_login:ban", true)
addEventHandler("cmta_login:ban", resourceRoot, function(result)
    if result == "0" then
		setPlayerHudComponentVisible ( "radar", false )  
		showChat(false)
		addEventHandler("onClientRender", getRootElement(), updateCamPosition)
		addEventHandler("onClientRender", getRootElement(), maskEffect)
		addEventHandler ( "onDgsMouseClick", getRootElement(), onclick)
		cmtaLoginPanel = true
		showCursor(true)
		createlogin()
		music=playSound("music.mp3",true)
		setSoundVolume(music, 0.3)
		myImage = dxCreateTexture( "speaker.png" ,"argb", false, "clamp" )
		muteimg = dgsCreateImage(20*px,700*py,50*px,50*py,myImage)
	else
	    dane_gracza = result
        setElementData(localPlayer,"player:info_ban",true)
        texture = dxCreateTexture( "bg.jpg" ,"argb", false, "clamp" )
        dgsCreateImage(0*px,0*py,1366*px,768*py,texture,false)
		baneffect3d = dgsCreateEffect3D(20)
		bansp = dgsCreateScrollPane(350*px,100*py,666*px,568*py,false,false)  
		banimg = dgsCreateImage(0,0,1,1,_,true,bansp,tocolor(0,0,0,140))  
		dgsEffect3DApplyToScrollPane(baneffect3d,bansp)
		textban = dgsCreateLabel(0*px,50*py,666*px,50*py,"Zostałeś(aś) zbanowany(a)!",false,banimg,tocolor(255,0,0))
		dgsSetFont( textban, font4 )
		dgsSetProperty(textban,"alignment",{"center","center"})
		textban2 = dgsCreateLabel(0*px,100*py,666*px,300*py,"#808080Nick: #DD6B20"..result[1]["nick"].." #808080[#DD6B20UID:"..result[1]["uid"].."#808080]\n#808080Serial: #DD6B20"..result[1]["serial"].."\n#808080Długość bana: #DD6B20"..result[1]["time"].."\n#808080Powód: #DD6B20"..dane_gracza[1]["reason"].."\n#808080Zbanowany przez: #DD6B20"..result[1]["banned_by"].."\n#808080Czas nałożenia bana: #DD6B20"..result[1]["add_date"].."",false,banimg)
		dgsSetFont( textban2, font3 )
		dgsSetProperty(textban2,"colorcoded",true)
		dgsSetProperty(textban2,"alignment",{"center","center"})
		textban3 = dgsCreateLabel(0*px,350*py,666*px,50*py,"#DD6B20Od bana możesz odwołać się na forum https://clickermta.pl/\n#ff2828⚠️ Pamiętaj, że bany na czas krótszy niż 24 godziny nie są sprawdzane!",false,banimg)
		dgsSetFont( textban3, font )
		dgsSetProperty(textban3,"colorcoded",true)
		dgsSetProperty(textban3,"alignment",{"center","center"})
		bancopybutton = dgsCreateButton( 50*px,450*py,266*px,30*py, "Skopiuj treść bana", false,banimg,false,false,false,false,false,false,false,tocolor(221,107,32),tocolor(255,40,40),tocolor(255,40,40))
		banquitbutton = dgsCreateButton( 350*px,450*py,266*px,30*py, "Wyjdź z serwera", false,banimg,false,false,false,false,false,false,false,tocolor(221,107,32),tocolor(255,40,40),tocolor(255,40,40))
        addEventHandler("onClientRender",root,gui)
		addEventHandler ( "onDgsMouseClick", getRootElement(), onbanclick)

	end
end)

function onbanclick ( btn, state )
	if btn == "left" and state == "down" and getElementData(localPlayer,"player:info_ban") then
    if source == bancopybutton then
		setClipboard("Nick: "..dane_gracza[1]["nick"].." [UID:"..dane_gracza[1]["uid"].."]\nSerial: "..dane_gracza[1]["serial"].."\nDługość bana: "..dane_gracza[1]["time"].."\nPowód: "..dane_gracza[1]["reason"].."\nZbanowany przez: "..dane_gracza[1]["banned_by"].."\nCzas nałożenia bana: "..dane_gracza[1]["add_date"].."")
	end
	if source == banquitbutton then
		triggerServerEvent("cmta_login:quit", resourceRoot)
	end
	end
end

function gui()
    showChat(false)
    showCursor(true)
    setPlayerHudComponentVisible ( "radar", false )  
end


function onclick ( btn, state )
	if btn == "left" or btn == "right" and state == "down" and cmtaLoginPanel == true then

		if source == img3 then
		 dgsMoveToBack( img3 )
		end
		if source == image3 then
		 dgsMoveToBack( image3 )
		end
	 end
	if btn == "left" and state == "down" and cmtaLoginPanel == true then
       if source == textregister then
		destroyElement(effect3d)
		destroyElement(sp)
		createregister()
	   end
       if source == textrecovery then
		destroyElement(effect3d)
		destroyElement(sp)
		createrecovery()
	   end
	   if source == textlogin then
		destroyElement(image)
		destroyElement(effect3d2)
		destroyElement(sp2)
		destroyElement(rndRect)
		createlogin()
	   end
	   if source == button then
		local login = dgsGetText ( edit1 )
		local password = dgsGetText ( edit2 )
		if string.len(login) < 3 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffLogin jest zbyt krótki.","error",4000) return end 
		triggerServerEvent("cmta_login:checklogin", resourceRoot, login, password)
	   end
		if source == button2 then
			local login = dgsGetText ( edit1 )
			local password = dgsGetText ( edit2 )
			local rpassword = dgsGetText ( edit3 )
			local pin = dgsGetText ( edit4 )
			local weblogin = dgsGetText ( edit5 )
			local webpassword = dgsGetText ( edit6 )
			local webemail = dgsGetText ( edit7 )
			if string.len(login) < 3 or string.len(login) > 24 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffTwój login musi składać się od 3-24 znaków.","error",4000) return end
			if string.len(password) < 3 or string.len(password) > 24 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffTwoje hasło musi składać się od 3-24 znaków.","error",4000) return end
			if password ~= rpassword then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffPoodane hasła różnią się od siebie.","error",4000) return end
			if not tonumber(pin) or pin:len() ~= 4 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffPIN musi składać się z 4 cyfr.","error",4000) return end
			if not string.find(webemail, "@") then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffWpisany E-mail jest nieprawidłowy\npodaj prawdziwy, aby móc odzyskać\nkonto.","error",4000) return end
			triggerServerEvent("cmta_login:register", resourceRoot, login, password,pin,weblogin,webpassword,webemail)
		end
		if source == pinbutton then
			local pin = dgsGetText ( edit8 )
			if not tonumber(pin) or string.len(pin) ~= 4 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffPIN musi składać się z 4 cyfr.","error",4000) return end
			triggerServerEvent("cmta_login:checkPIN", resourceRoot, pin)

		end
	    if source == spawnbutton1 then
			setElementPosition(localPlayer,1310.24,-1375.42,13.64)
			spawn_player()
		elseif source == spawnbutton2 then
			setElementPosition(localPlayer,-2279, 157.3, 35.1)
			spawn_player()
		elseif source == spawnbutton3 then
			setElementPosition(localPlayer,2438.22,2376.49,10.82)
			spawn_player()
		elseif source == spawnbutton4 then
			setElementPosition(localPlayer,-180.95,1089.99,19.74)
			spawn_player()
		elseif source == spawnbutton5 then
		
		elseif source == spawnbutton6 then
		
		elseif source == spawnbutton7 then
			triggerServerEvent("cmta_login:spawnPlayer", resourceRoot)
			spawn_player()
		elseif source == spawnbutton8 then
			setElementPosition(localPlayer,2371.11,-642.64,127.67)
			spawn_player()
		elseif source == spawnbutton9 then
			setElementPosition(localPlayer,2659.49,-2043.92,13.55)
			spawn_player()
		end



		if source == recoveryback then
			destroyElement(effect3d5)
			destroyElement(sp5)
			createlogin()
		end
		if source == recoveryback2 then
			destroyElement(effect3d6)
			destroyElement(sp6)
			createlogin()
		end
		if source == pinrecovery then
			local login = dgsGetText ( edit9 )
			local email = dgsGetText ( edit10 )
			local pin = dgsGetText ( edit11 )
			if string.len(login) < 3 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffTwój login jest zbyt krótki.","error",4000) return end
			if not string.find(email, "@") then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffWpisany E-mail jest nieprawidłowy.","error",4000) return end
			if not tonumber(pin) or pin:len() ~= 4 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffPIN musi składać się z 4 cyfr (0-9).","error",4000) return end
			
			triggerServerEvent("cmta_login:recovery_password", resourceRoot, login,email,pin)
		end
		if source == pinrecovery2 then
			local code = dgsGetText ( edit12 )
			local pass = dgsGetText ( edit13 )
			local rpass = dgsGetText ( edit14 )
			if pass ~= rpass then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffPodane hasła różnią się od siebie.","error",4000) return end
			if code:len() ~= 10 then exports['cmta-notyfikacje']:sendNotification("#FF0000Wykryto nieprawidłowość!\n#ffffffKod weryfikacyjny jest nieprawidłowy.","error",4000) return end
			triggerServerEvent("cmta_login:change_password", resourceRoot, recoverylogin,code,pass)
		end

	--	refreshmap()
	--	createspawn()
	   
	   if source == muteimg then
		if getSoundVolume(music) > 0 then
		setSoundVolume(music,0)
		if isElement(muteimg) then destroyElement(muteimg) end		
		myImage = dxCreateTexture( "speakermute.png" ,"argb", false, "clamp" )
		muteimg = dgsCreateImage(20*px,700*py,50*px,50*py,myImage)
        else
		setSoundVolume(music,0.3)
		if isElement(muteimg) then destroyElement(muteimg)end		
		myImage = dxCreateTexture( "speaker.png" ,"argb", false, "clamp" )
		muteimg = dgsCreateImage(20*px,700*py,50*px,50*py,myImage)
		end
	end 
	end
end


function spawn_player()
	destroyElement(muteimg)
	destroyElement(effect3d3)
	destroyElement(sp3)			
	showChat(true)
	showCursor(false)
	setPlayerHudComponentVisible ( "radar", true )  
	removeEventHandler("onClientRender", getRootElement(), updateCamPosition)
	removeEventHandler("onClientRender", getRootElement(), maskEffect)
	removeEventHandler ( "onDgsMouseClick", getRootElement(), onclick)
	cmtaLoginPanel = false
	setCameraTarget(localPlayer)
	triggerServerEvent("cmta_login:checkbonus",resourceRoot)
	exports["cmta-hud"]:createhud(localPlayer) 
	stopSound(music)

end

function load_rememberMe()
    local xml=xmlLoadFile("datasave.xml")
    if not xml then return end
        
    local xmlNode=xmlFindChild(xml, "login", 0)
    local login=xmlNodeGetValue(xmlNode)
    if login then
		dgsSetText(edit1, tostring(login))
    end
    local xmlNode=xmlFindChild(xml, "pass", 0)
    local passwd=xmlNodeGetValue(xmlNode)
    if passwd then 
		dgsSetText(edit2, teaDecode(tostring(passwd),">,qx*+=zb9i6)Z2"))
	end
	local xmlNode=xmlFindChild(xml, "activebutton", 0)
    local buttonch=xmlNodeGetValue(xmlNode)
    if buttonch then
		dgsCheckBoxSetSelected(checklog,true)
	end
end

function save_rememberMe()
    if dgsCheckBoxGetSelected(checklog) then
        local xml=xmlCreateFile("datasave.xml", "auth")
        if not xml then return end
        xmlNodeSetValue(xmlCreateChild(xml, "login"), dgsGetText (edit1))
		xmlNodeSetValue(xmlCreateChild(xml, "pass"), teaEncode(dgsGetText (edit2),">,qx*+=zb9i6)Z2"))
		xmlNodeSetValue(xmlCreateChild(xml, "activebutton"), "tak")
        xmlSaveFile(xml)
	else
		fileDelete("datasave.xml")
	end
end